package com.techstar.ats.codec.live.decoder;

import io.netty.buffer.ByteBuf;
import com.techstar.ats.codec.MessageDecoder;
import com.techstar.ats.dxp.live.F06SignalRoute;
import com.techstar.ats.dxp.live.rep.F06SignalRouteStatus;

public enum F06SignalRouteStatusDecoder implements MessageDecoder<F06SignalRouteStatus> {
	INSTANCE;

	public F06SignalRouteStatus create() {
		return new F06SignalRouteStatus();
	}

	public void decode(ByteBuf buf, F06SignalRouteStatus value) {
		value.line = buf.readUnsignedShort();
		value.rtu = buf.readUnsignedShort();
		int cnt = buf.readUnsignedShort();

		for(int i = 0; i < cnt; ++i) {
			F06SignalRoute route = F06SignalRouteDecoder.INSTANCE.create();
			F06SignalRouteDecoder.INSTANCE.decode(buf, route);
			value.routes.add(route);
		}

	}
}
